package com.neu.servlet.ww;

import com.neu.service.klz.Addservice;
import com.neu.service.ww.GoodsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "SearchCarServlet",urlPatterns = "/SearchCarServlet.do")
public class SearchCarServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session=request.getSession();
        Map<String,Object> userMap= (Map<String, Object>) session.getAttribute("user");
        if (userMap!=null && !userMap.isEmpty()){
            String u_id=userMap.get("U_ID").toString();
            Addservice addservice=new Addservice();
            List<Map<String,Object>> addressList=addservice.dofindById(u_id);
            System.out.println(addressList);
            session.setAttribute("addressList",addressList);
            request.getRequestDispatcher("/WEB-INF/views/car.jsp").forward(request,response);
        }else {
            response.sendRedirect("/HAIGO/login.jsp");
        }
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
